/**$Licence:
 *   Use this however/wherever you like, just don't blame me if it breaks anything.
 *   Copyright (C) 2008 - 2012 xingsheng.zhu@gmail.com All rights reserved.
 */
package com.blazemina.mina;

import java.net.SocketAddress;

import org.apache.mina.core.session.IoSession;

import com.blazemina.message.Message;

/**
 * wrap {@link IoSession},所有实现都依赖于IoSession
 * 
 * @author JackChu
 * @version 1.0.0 2012-1-11 下午4:38:27
 */
public interface Session {

	public long getId();

	/**
	 * 发送消息,所有消息的输出，都是经过这个方法
	 * 
	 * @param message
	 */
	public void send(Message message);

	public void close(boolean immediately);

	public SocketAddress getRemoteAddress();

	public Object setAttribute(Object key, Object value);

	public Object getAttribute(Object key);
	
	/**
     * Returns <code>true</code> if this session is connected with remote peer.
     */
    boolean isConnected();

    /**
     * Returns <code>true</tt> if and only if this session is being closed
     * (but not disconnected yet) or is closed.
     */
    boolean isClosing();
    
    /**
     * 设置空闲时间
     * @param seconds
     */
    void setIdleTime(int seconds);

}
